/*
 * heap.h
 *
 *  Created on: 2011-8-19
 *      Author: jfhu
 */

#ifndef _HEAP_H_
#define _HEAP_H_

typedef struct _heap {
	int *arr;
	int capacity;
	int size;
	int d;
} heap, *pHeap;

/* Make heap */
pHeap makeheap(int *ary, int n, int d);

/* Destroy heap */
void destroyHeap(pHeap h);

/* Insert <i>i</i> */
void insert(int i, pHeap h);
/* Delete the minimum element */
int deletemin(pHeap h);
/* Delete the <i>i</i> element */
/* void delete(int i, pHeap h); */

/* Find the minimum value of the heap */
int findmin(pHeap h);

/* Sift up */
void siftup(int i, int index, pHeap h);

/* Sift down */
void siftdown(int i, int index, pHeap h);

/* Minimum children value */
int minchild(int index, const pHeap h);

/* Print the string of heap */
void printfHeap(const pHeap h);
#endif /* HEAP_H_ */
